//
//  LECommitCell.m
//  LoveExpressBusiness
//
//  Created by 刘甲奇 on 2017/5/11.
//  Copyright © 2017年 DFH. All rights reserved.
//

#import "LECommitCell.h"
#import "MakerTools.h"
@interface LECommitCell()

@property (weak, nonatomic) IBOutlet UILabel *serviceNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *star1;
@property (weak, nonatomic) IBOutlet UIImageView *star2;
@property (weak, nonatomic) IBOutlet UIImageView *star3;
@property (weak, nonatomic) IBOutlet UIImageView *star4;
@property (weak, nonatomic) IBOutlet UIImageView *star5;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@property (weak, nonatomic) IBOutlet UIButton *explainButton;
@property (weak, nonatomic) IBOutlet UILabel *commitContentLabel;
@property (weak, nonatomic) IBOutlet UILabel *explainContentLabel;

// block
@property(nonatomic,strong)explainBlock block;


@end

@implementation LECommitCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (void)commitCellClick:(explainBlock)block
{
    self.block = block;
}
- (void)setModel:(LECommitModel *)model
{
    _model = model;
    self.serviceNameLabel.text = model.geval_goodsname;
    self.timeLabel.text = [MakerTools getFormatTime:model.geval_addtime];
    self.commitContentLabel.text = model.geval_content;
    self.explainContentLabel.text = model.geval_explain;
    self.phoneLabel.text = model.geval_frommembername;
    [self setCommitGrade:[model.geval_scores intValue]];
    
}
#pragma mark- privateMethod

/**
 设置评分

 @param grade
 */
- (void)setCommitGrade:(int)grade
{
    UIImage *offImage = [UIImage imageNamed:@"star_off"];
    UIImage *onImage = [UIImage imageNamed:@"star_on"];
    
    switch (grade) {
        case 0:
        {
            [self setStarOff];
        }
            break;
        case 1:
        {

            self.star1.image = onImage;
            self.star2.image = offImage;
            self.star3.image = offImage;
            self.star4.image = offImage;
            self.star5.image = offImage;
        }
            break;
        case 2:
        {
            self.star1.image = onImage;
            self.star2.image = onImage;
            self.star3.image = offImage;
            self.star4.image = offImage;
            self.star5.image = offImage;
        }
            break;
        case 3:
        {
            self.star1.image = onImage;
            self.star2.image = onImage;
            self.star3.image = onImage;
            self.star4.image = offImage;
            self.star5.image = offImage;
        }
            break;
        case 4:
        {
            self.star1.image = onImage;
            self.star2.image = onImage;
            self.star3.image = onImage;
            self.star4.image = onImage;
            self.star5.image = offImage;
        }
            break;
        case 5:
        {
            self.star1.image = onImage;
            self.star2.image = onImage;
            self.star3.image = onImage;
            self.star4.image = onImage;
            self.star5.image = onImage;
        }
            break;
            
        default:
        {
            [self setStarOff];
        }
            break;
    }
}
- (void)setStarOff
{
    UIImage *offImage = [UIImage imageNamed:@"star_off"];
    self.star1.image = offImage;
    self.star2.image = offImage;
    self.star3.image = offImage;
    self.star4.image = offImage;
    self.star5.image = offImage;
}
- (IBAction)explainClick:(UIButton *)sender
{
    self.block(self.model);
}


@end







